<?php

namespace App\Http\Middleware;

use App\Model\Message;
use Closure;

class DomainAuth2
{
    /**
     * Handle an incoming request.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  \Closure  $next
     * @return mixed
     */
    public function handle($request, Closure $next)
    {
        $agent = $_SERVER['HTTP_USER_AGENT'];
        if(strpos($agent,"NetFront") || strpos($agent,"iPhone") || strpos($agent,"MIDP-2.0") || strpos($agent,"Opera Mini") || strpos($agent,"UCWEB") || strpos($agent,"Android") || strpos($agent,"Windows CE") || strpos($agent,"SymbianOS")) {
            return $next($request);
        }else{
            $url = "http://www.qiyiguo.tv".'/'.$request->path();
            return response("<script>location.href="."'".$url."'"."</script>");
        }
    }
}
